using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouseLook : MonoBehaviour
{
    [SerializeField]private Transform characterTransform;
    public float MouseSensitivity = 5f;
    private Vector3 cameraRotation;
    public Vector2 LimitAngle = new Vector2(-75.0f, 75.0f);
    void Start()
    {
        
    }

    void Update()
    {
        var tmp_MouseX = Input.GetAxis("Mouse X");
        var tmp_MouseY = Input.GetAxis("Mouse Y");

        cameraRotation.x -= tmp_MouseY * MouseSensitivity;
        cameraRotation.y += tmp_MouseX * MouseSensitivity;

        cameraRotation.x = Mathf.Clamp(cameraRotation.x, LimitAngle.x, LimitAngle.y);

        transform.rotation = Quaternion.Euler(cameraRotation.x, cameraRotation.y, 0f);
        characterTransform.rotation = Quaternion.Euler(0, cameraRotation.y, 0);
    }
}
